package xyz.liut.ee.api

import jakarta.servlet.annotation.MultipartConfig
import jakarta.servlet.annotation.WebServlet
import jakarta.servlet.http.HttpServletRequest
import jakarta.servlet.http.HttpServletResponse
import xyz.liut.ee.req.getSimpleReqInfo
import xyz.liut.ee.web.BaseNoDefaultServlet
import xyz.liut.ee.web.toJsonString

/**
 * formhtml test
 */
@WebServlet("/echohtml")
@MultipartConfig
class EchoHtml : BaseNoDefaultServlet() {

    override fun service(req: HttpServletRequest, resp: HttpServletResponse) {
        super.service(req, resp)

        val reqInfo = req.getSimpleReqInfo()

        val respHtml = """
            <!DOCTYPE html>
            <html lang="zh">
            <head><title>form html test</title></head>
            <body>
            request ->
            <pre>${reqInfo.toJsonString()}</pre>
            </body>
        """.trimIndent()

        resp.contentType = "text/html; charset=utf-8"

        resp.writer?.println(respHtml)

    }


}
